package br.com.commerj.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DAO {
	
	Connection c;
	PreparedStatement p;
	ResultSet r;
	Statement s;
	
	public Connection getConnection(){
		String host;
		String database;
		String username;
		String porta;
		String password;

		host = "localhost";
		database = "commerj";
		username = "root";
		porta = "3306";
		password = "caca060405";
		try{
			if (c == null) {
				DriverManager.registerDriver(new com.mysql.jdbc.Driver());
				String strConexao = "jdbc:mysql://" + host + ":" + porta + "/" + database;
				c = DriverManager.getConnection(strConexao, username,password);
				c.setAutoCommit(false);
				c.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
				}
		}catch(SQLException e){
			System.out.println("Erro ao Obter a Conexao: "+e.getMessage());
		}
		return c;
	}

}
